package drawing;

import java.io.File;

import malaria_acd.AddNewNameActivity;

import project.malaria.malaria_acd.R;
import project.malaria.malaria_acd.R.id;
import project.malaria.malaria_acd.R.layout;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;

public class ImageViewerActivity extends Activity {
	/***Variable:: SharedPreference***/
	public static final String PREFS_NAME = "Drawing";
	public static  String shDrawHouse;
	private  SharedPreferences share;
	
	/****Variable :: Widget***/
	private ImageView back,ViewImage;
	private Bitmap myBitmap;
	
	/***Variable :: Content ***/
	private String root;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_image_viewer);
		initializeValue();
		
		String filename = share.getString(shDrawHouse, "-");
	
		File imgFile = new  File(root + "/ACD/images/"+filename);
		if(imgFile.exists()){
		    myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
		    ViewImage.setImageBitmap(myBitmap);

		}
		else
		{
			System.out.println("IMAGE NOT FOUND!");
		}
		
		back.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
			
				 onBackPressed();
			}
		});		
	}

		public void funcEdit(View v) {		
			funcEdit();
		}
		
		public void funcEdit() {
			finish();
			 Intent i = new Intent(ImageViewerActivity.this, DrawHousenNoActivity.class);
			 startActivityForResult(i,0);	
		}

		private void initializeValue()
		{
			back = (ImageView) findViewById(R.id.imageView1);
			share = this.getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
			root = Environment.getExternalStorageDirectory().toString();
			ViewImage = (ImageView) findViewById(R.id.viewname);
			

		}
}
